package parser;

public class PCreateTable {
//attribution
	public String tableName;
	public String []attribution;
	public String []type;
	public String key;
//method
	PCreateTable(String cmd){
		String [] sAry;
		String s;
		sAry = cmd.split("CREATE TABLE\\s+");
		try{
			int pos = sAry[1].indexOf('(');
			tableName = sAry[1].substring(0, pos);
			s = sAry[1].substring(pos+1);
			if(s.endsWith(")")){
				s = s.substring(0, s.length()-1);
			}
			sAry = s.split("\\,\\s*");
			attribution = new String[sAry.length];
			type = new String[sAry.length];
			getAttribution(sAry);
			//System.out.print("");
		}
		catch (RuntimeException e){
			//TODO
		}
	}//end PCreateTable()
	void getAttribution(String []sAry){
		String []ss;
		for(int i=0; i<sAry.length; i++){
			ss = sAry[i].split("\\s+");
			if(ss.length>=3)
				key = ss[0];
			attribution[i] = ss[0];
			type[i] = ss[1];
		}
	}//end getAttribution
}
